package com.bike.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bike.entity.HhVersion;
import com.bike.mapper.HhVersionMapper;
import com.bike.util.PageData;
import com.bike.util.TransFerUtil;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;

@Service
public class HhVersionServiceImpl extends BaseServcieImpl  {

	@Autowired
	HhVersionMapper hhVersionMapper;
	
	/**
	* 保存
	*/
	public void saveOrUpdate(PageData pd, HhVersion record) {
		if(pd.getLong("itemId")>0){
			 //编辑
			hhVersionMapper.updateByPrimaryKeySelective(record);
		}else{
			hhVersionMapper.insertSelective(record);
		}
	}
	
	/**
	* 删除
	*/
	public int deleteHhVersionById(long itemId) {
		return hhVersionMapper.deleteByPrimaryKey(itemId);
	}
	
	/**
	*列表分页
	*/
	public PageData selectHhVersionList(PageData pd) {
		PageData result=new PageData();
		PageBounds pageBounds=(PageBounds) pd.get("pageB");
		 
		List<HhVersion> records= hhVersionMapper.selectByPage(pd,pageBounds);
		result.put("rows",records );
		result.put("total", ((PageList<HhVersion>) records).getPaginator().getTotalCount());
		return result;
	}
	 
	/**
	*列表(全部)
	*/
	public List<HhVersion> listAll(PageData pd) {
		return  hhVersionMapper.selectAll(pd);
	}
	
	/**
	* 通过id获取数据
	*/
	public HhVersion selectByHhVersionId(Long itemId) {
		return hhVersionMapper.selectByPrimaryKey(itemId);
	}
}

